home *** CD-ROM | disk | FTP | other *** search
-
-
-
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333)))) 22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222)))) AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333))))
-
-
-
- NNNNAAAAMMMMEEEE
- AutoLoader - load subroutines only on demand
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- package Foo;
- use AutoLoader 'AUTOLOAD'; # import the default AUTOLOAD subroutine
-
- package Bar;
- use AutoLoader; # don't import AUTOLOAD, define our own
- sub AUTOLOAD {
- ...
- $AutoLoader::AUTOLOAD = "...";
- goto &AutoLoader::AUTOLOAD;
- }
-
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- The AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr module works with the AAAAuuuuttttooooSSSSpppplllliiiitttt module and
- the __END__ token to defer the loading of some subroutines
- until they are used rather than loading them all at once.
-
- To use AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr, the author of a module has to place the
- definitions of subroutines to be autoloaded after an __END__
- token. (See the _p_e_r_l_d_a_t_a manpage.) The AAAAuuuuttttooooSSSSpppplllliiiitttt module
- can then be run manually to extract the definitions into
- individual files _a_u_t_o/_f_u_n_c_n_a_m_e._a_l.
-
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr implements an AUTOLOAD subroutine. When an
- undefined subroutine in is called in a client module of
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr, AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr's AUTOLOAD subroutine attempts to
- locate the subroutine in a file with a name related to the
- location of the file from which the client module was read.
- As an example, if _P_O_S_I_X._p_m is located in
- /_u_s_r/_l_o_c_a_l/_l_i_b/_p_e_r_l_5/_P_O_S_I_X._p_m, AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr will look for perl
- subroutines PPPPOOOOSSSSIIIIXXXX in /_u_s_r/_l_o_c_a_l/_l_i_b/_p_e_r_l_5/_a_u_t_o/_P_O_S_I_X/*._a_l,
- where the .al file has the same name as the subroutine, sans
- package. If such a file exists, AUTOLOAD will read and
- evaluate it, thus (presumably) defining the needed
- subroutine. AUTOLOAD will then goto the newly defined
- subroutine.
-
- Once this process completes for a given funtion, it is
- defined, so future calls to the subroutine will bypass the
- AUTOLOAD mechanism.
-
- SSSSuuuubbbbrrrroooouuuuttttiiiinnnneeee SSSSttttuuuubbbbssss
-
- In order for object method lookup and/or prototype checking
- to operate correctly even when methods have not yet been
- defined it is necessary to "forward declare" each subroutine
- (as in sub NAME;). See the section on _S_Y_N_O_P_S_I_S in the
- _p_e_r_l_s_u_b manpage. Such forward declaration creates
-
-
-
- Page 1 (printed 10/23/98)
-
-
-
-
-
-
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333)))) 22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222)))) AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333))))
-
-
-
- "subroutine stubs", which are place holders with no code.
-
- The AutoSplit and AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr modules automate the creation
- of forward declarations. The AutoSplit module creates an
- 'index' file containing forward declarations of all the
- AutoSplit subroutines. When the AutoLoader module is 'use'd
- it loads these declarations into its callers package.
-
- Because of this mechanism it is important that AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr is
- always used and not required.
-
- UUUUssssiiiinnnngggg AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr's AUTOLOAD Subroutine
-
- In order to use AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr's AUTOLOAD subroutine you _m_u_s_t
- explicitly import it:
-
- use AutoLoader 'AUTOLOAD';
-
-
- OOOOvvvveeeerrrrrrrriiiiddddiiiinnnngggg AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr's AUTOLOAD Subroutine
-
- Some modules, mainly extensions, provide their own AUTOLOAD
- subroutines. They typically need to check for some special
- cases (such as constants) and then fallback to AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr's
- AUTOLOAD for the rest.
-
- Such modules should _n_o_t import AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr's AUTOLOAD
- subroutine. Instead, they should define their own AUTOLOAD
- subroutines along these lines:
-
- use AutoLoader;
- use Carp;
-
- sub AUTOLOAD {
- my $constname;
- ($constname = $AUTOLOAD) =~ s/.*:://;
- my $val = constant($constname, @_ ? $_[0] : 0);
- if ($! != 0) {
- if ($! =~ /Invalid/) {
- $AutoLoader::AUTOLOAD = $AUTOLOAD;
- goto &AutoLoader::AUTOLOAD;
- }
- else {
- croak "Your vendor has not defined constant $constname";
- }
- }
- *$AUTOLOAD = sub { $val }; # same as: eval "sub $AUTOLOAD { $val }";
- goto &$AUTOLOAD;
- }
-
- If any module's own AUTOLOAD subroutine has no need to
- fallback to the AutoLoader's AUTOLOAD subroutine (because it
-
-
-
- Page 2 (printed 10/23/98)
-
-
-
-
-
-
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333)))) 22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222)))) AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333))))
-
-
-
- doesn't have any AutoSplit subroutines), then that module
- should not use AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr at all.
-
- PPPPaaaacccckkkkaaaaggggeeee LLLLeeeexxxxiiiiccccaaaallllssss
-
- Package lexicals declared with my in the main block of a
- package using AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr will not be visible to auto-loaded
- subroutines, due to the fact that the given scope ends at
- the __END__ marker. A module using such variables as
- package globals will not work properly under the AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr.
-
- The vars pragma (see the section on _v_a_r_s in the _p_e_r_l_m_o_d
- manpage) may be used in such situations as an alternative to
- explicitly qualifying all globals with the package
- namespace. Variables pre-declared with this pragma will be
- visible to any autoloaded routines (but will not be
- invisible outside the package, unfortunately).
-
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr vs. SSSSeeeellllffffLLLLooooaaaaddddeeeerrrr
-
- The AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr is similar in purpose to SSSSeeeellllffffLLLLooooaaaaddddeeeerrrr: both
- delay the loading of subroutines.
-
- SSSSeeeellllffffLLLLooooaaaaddddeeeerrrr uses the __DATA__ marker rather than __END__.
- While this avoids the use of a hierarchy of disk files and
- the associated open/close for each routine loaded,
- SSSSeeeellllffffLLLLooooaaaaddddeeeerrrr suffers a startup speed disadvantage in the one-
- time parsing of the lines after __DATA__, after which
- routines are cached. SSSSeeeellllffffLLLLooooaaaaddddeeeerrrr can also handle multiple
- packages in a file.
-
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr only reads code as it is requested, and in many
- cases should be faster, but requires a machanism like
- AAAAuuuuttttooooSSSSpppplllliiiitttt be used to create the individual files. the
- _E_x_t_U_t_i_l_s::_M_a_k_e_M_a_k_e_r manpage will invoke AAAAuuuuttttooooSSSSpppplllliiiitttt
- automatically if AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr is used in a module source file.
-
- CCCCAAAAVVVVEEEEAAAATTTTSSSS
- AutoLoaders prior to Perl 5.002 had a slightly different
- interface. Any old modules which use AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr should be
- changed to the new calling style. Typically this just means
- changing a require to a use, adding the explicit 'AUTOLOAD'
- import if needed, and removing AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr from @ISA.
-
- On systems with restrictions on file name length, the file
- corresponding to a subroutine may have a shorter name that
- the routine itself. This can lead to conflicting file
- names. The _A_u_t_o_S_p_l_i_t package warns of these potential
- conflicts when used to split a module.
-
- AutoLoader may fail to find the autosplit files (or even
- find the wrong ones) in cases where @INC contains relative
-
-
-
- Page 3 (printed 10/23/98)
-
-
-
-
-
-
- AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333)))) 22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222)))) AAAAuuuuttttooooLLLLooooaaaaddddeeeerrrr((((3333))))
-
-
-
- paths, aaaannnndddd the program does chdir.
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- the _S_e_l_f_L_o_a_d_e_r manpage - an autoloader that doesn't use
- external files.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 4 (printed 10/23/98)
-
-
-
-